import http from "./http";
import { urlPath1, urlPath2, urlPath3 } from "./const";

/**
 * 两市交易总量
 * @param {Object} option
 * @param {Number} option.marketType - all-全市场,sh-沪市,sz-深市
 * @return {Promise} Array
 */
export async function getChartList(option) {
  const url = "/margin/history/chart";
  const params = {
    marketType: "all",
    ...option,
  };
  const res = await http.get(urlPath1 + url, { params });
  return res.data;
}

/**
 * 南北向资金首页
 * @return {Promise} Array
 */
export async function getIndexData() {
  const url = "/snfund/index";
  const res = await http.get(urlPath2 + url);
  return res.data;
}

/**
 * 头条新闻
 * @param {Object}
 * @return {Promise} Array
 */
export async function getHeadList(option) {
  const url = "/stream/info/news/head/list";
  const params = {
    pageNum: 1,
    pageSize: 7,
    ...option,
  };
  const res = await http.get(urlPath3 + url, { params });
  return res.data;
}

/**
 * 上市公司新闻
 * @param {Object}
 * @return {Promise} Array
 */
export async function getCompanyList(option) {
  const url = "/stream/info/news/company/list";
  const params = {
    pageNum: 1,
    pageSize: 7,
    ...option,
  };
  const res = await http.get(urlPath3 + url, { params });
  return res.data;
}

/**
 * 新闻详情
 * @param {Object}
 * @return {Promise} Array
 */
export async function getNewsDetail(option) {
  const url = "/stream/info/news/detail";
  const params = {
    guid: "",
    ...option,
  };
  const res = await http.get(urlPath3 + url, { params });
  return res.data;
}
